package com.wxd.service.impl;

import com.wxd.service.HelloService;

import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;

public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHelloA() {
        sleepRandomly();
        return "hello A";
    }

    @Override
    public String sayHelloB() {
        sleepRandomly();
        return "hello B";
    }

    @Override
    public String sayHelloC() {
        sleepRandomly();
        return "hello C";
    }

    // 随机休眠0-100ms
    private void sleepRandomly() {
        try {
            TimeUnit.MILLISECONDS.sleep(new SecureRandom().nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
